home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
tools
/
pcd2
/
src
/
pcddec.has
< prev
next >
Wrap
Text File
|
1997-01-02
|
5KB
|
270 lines
.include doscall.mac
.cpu 68000
.xdef YCC2XHI_S,YCC2XHI_X,YCC2XHI_S2
.xdef Make_Table
.xdef PCD_WORK,PCD_WORK_Y,PCD_WORK_RGB
.xdef X1391,X1865,X441,X949,X2271
* in d0.w=File Handle
* in a0.l=Graph work ptr
* in a1.l=dec work ptr
* in a2.l=Graph work ptr 2
.offset 0
READ_BYTE .ds.w 1 * XSIZE*3 読み込みバイト数
OSET_Y1 .ds.w 1 * XSIZE*4 2ライン目のYデータオフセット
XlpCOUNT .ds.w 1 * XSIZE/2-1 or XSIZE/6-1 Xループカウンタ値
YlpCOUNT .ds.w 1 * YSIZE/2-1 Yループカウンタ値
CCDEC_COUNT .ds.w 1 * XSIZE/2-1
YDAT_COUNT .ds.w 1 * XSIZE*2-1 Yデータ展開カウンタ値
LINE_OSET1 .ds.w 1 * 1ラインのバイト数
LINE_OSET2 .ds.w 1 * 2ラインのバイト数
TO32 macro dreg
lsl.l #3,dreg
swap dreg
tst.w dreg
bpl @f
moveq.l #0,dreg
@@: cmp.w #$1f,dreg
ble @f
move.w #$1f,dreg
@@:
.endm
CCLOAD macro
move.l (a2)+,d3
move.l (a2)+,d4
move.l (a2)+,d5
endm
YDEC macro regA,regB
move.l (regA)+,d0
move.l d0,d1
move.l d0,d2
add.l d3,d0
add.l d4,d1
add.l d5,d2
TO32 d0
TO32 d1
TO32 d2
lsl.w #5,d1
add.w d0,d1
lsl.w #5,d1
add.w d2,d1
add.w d1,d1
move.w d1,(regB)+
endm
Y0DEC macro
YDEC a0,a4
endm
Y1DEC macro
YDEC a1,a5
endm
DEC_PRE macro
movem.l d1-d7/a0-a6,-(sp)
move.l a1,(DEC_WORK)
move.l a1,a3
move.w (READ_BYTE,a3),-(sp)
clr.w -(sp)
pea PCD_WORK
move.w d0,-(sp) * DOS _READのスタック設定完了
move.w (YlpCOUNT,a3),d7 * Y方向ループカウンタ
move.l a0,a6
2: DOS _READ
cmp.w (READ_BYTE,a3),d0 * DOS _READにミスしたか?
bne READ_ERR_BREAK
swap d7
move.w (YDAT_COUNT,a3),d7 * 2ライン分
lea.l (PCD_WORK),a0
lea.l (PCD_WORK_Y),a1
lea.l (X1391),a2
@@: moveq.l #0,d0
move.b (a0)+,d0
add.w d0,d0
add.w d0,d0
move.l (a2,d0.w),(a1)+
dbra d7,@b
move.l a6,-(sp)
lea.l (a0),a1 * (a0)=Cb
move.w (CCDEC_COUNT,a3),d7 * CCデコードカウンタ値
add.w d7,a1
addq.w #1,a1 * (a1)=Cr
lea.l (X1865),a2
lea.l (X441),a3
lea.l (X949),a4
lea.l (X2271),a5
lea.l (PCD_WORK_RGB),a6
@@: moveq.l #0,d0
move.b (a1)+,d0
add.w d0,d0
add.w d0,d0
move.l (a2,d0.w),(a6)+
move.l (a4,d0.w),d1
moveq.l #0,d0
move.b (a0)+,d0
add.w d0,d0
add.w d0,d0
add.l (a3,d0.w),d1
move.l d1,(a6)+
move.l (a5,d0.w),(a6)+
dbra d7,@b
move.l (DEC_WORK),a3
move.l (sp)+,a6
lea.l (PCD_WORK_Y),a0
move.w (OSET_Y1,a3),a1
adda.l a0,a1
lea.l (PCD_WORK_RGB),a2
lea.l (a6),a4
move.w (LINE_OSET1,a3),a5
adda.l a6,a5
endm
*------------------------------
* フォトYCC→Xハイカラー変換
* フルサイズ展開
*------------------------------
.text
.align 4
YCC2XHI_S:
DEC_PRE
move.w (XlpCOUNT,a3),d7
1: CCLOAD
Y0DEC
Y0DEC
Y1DEC
Y1DEC
dbra d7,1b
add.w (LINE_OSET2,a3),a6
swap d7
dbra d7,2b
lea.l (10,sp),sp
moveq.l #0,d0
movem.l (sp)+,d1-d7/a0-a6
rts
*------------------------------
* フォトYCC→Xハイカラー変換
* X*2/3,Yサイズに展開する
*------------------------------
.align 4
YCC2XHI_X:
DEC_PRE
move.w (XlpCOUNT,a3),d7
1: CCLOAD
Y0DEC
Y0DEC
Y1DEC
Y1DEC
addq.l #4,a0
addq.l #4,a1
CCLOAD
Y0DEC
Y1DEC
CCLOAD
Y0DEC
Y1DEC
addq.l #4,a0
addq.l #4,a1
dbra d7,1b
add.w (LINE_OSET2,a3),a6
swap d7
dbra d7,2b
lea.l (10,sp),sp
moveq.l #0,d0
movem.l (sp)+,d1-d7/a0-a6
rts
*------------------------------
* フォトYCC→Xハイカラー変換
* フルサイズ展開(512+256,512)
*------------------------------
.text
.align 4
YCC2XHI_S2:
move.l a2,(GraphWork)
DEC_PRE
move.w #255,d7
1: CCLOAD
Y0DEC
Y0DEC
Y1DEC
Y1DEC
dbra d7,1b
move.l a6,-(sp)
move.l GraphWork,a6
move.l (a6)+,a4
move.l (a6)+,a5
move.l a6,GraphWork
move.l (sp)+,a6
move.w #127,d7
1: CCLOAD
Y0DEC
Y0DEC
Y1DEC
Y1DEC
dbra d7,1b
add.w (LINE_OSET2,a3),a6
swap d7
dbra d7,2b
lea.l (10,sp),sp
moveq.l #0,d0
movem.l (sp)+,d1-d7/a0-a6
rts
*------------------------------
* 読み込みエラー
*------------------------------
READ_ERR_BREAK:
lea.l (10,sp),sp
moveq.l #-1,d0
movem.l (sp)+,d1-d7/a0-a6
rts
*------------------------------
*乗算テーブルを作成します。
*------------------------------
Make_Table:
movem.l d0-d7/a0-a6,-(sp)
lea.l (X1391),a0
move.l #1391,d1
mulu.w d0,d1
divu.w #100,d1
ext.l d1
moveq.l #0,d0
bsr MULMAIN
lea.l (X1865),a0
move.l #1865,d1
move.l #-255023,d0
bsr MULMAIN
lea.l (X441),a0
move.l #-441,d1
moveq.l #0,d0
bsr MULMAIN
lea.l (X949),a0
move.l #-949,d1
move.l #199313,d0
bsr MULMAIN
lea.l (X2271),a0
move.l #2271,d1
move.l #-353784,d0
bsr MULMAIN
movem.l (sp)+,d0-d7/a0-a6
rts
MULMAIN:
move.w #255,d7
@@: move.l d0,(a0)+
add.l d1,d0
dbra d7,@b
rts
.bss
.align 4 * テーブルの実際の内容
X1391: .ds.l 256 * n*1391
X1865: .ds.l 256 * n*1865-255023
X441: .ds.l 256 * n*-441
X949: .ds.l 256 * n*-949+199313
X2271: .ds.l 256 * n*2271-353784
GraphWork: .ds.l 1
DEC_WORK: .ds.l 1
PCD_WORK_Y: .ds.l 768*2
PCD_WORK_RGB: .ds.l 768*3/2
PCD_WORK: .ds.b 768*3